package cn.itsource.basic.config.interceptor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 声明springmvc的配置信息
 */
@Configuration
public class PetHomeConfigurer implements WebMvcConfigurer {

    @Autowired
    private LoginInterceptor loginInterceptor;

    /**
     * 注册拦截器
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //注册
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/**") //拦截所有的路径
                .excludePathPatterns("/**/login","/file/**","/shop/settlement")
                .excludePathPatterns("/wechat/**","/user/sendmobilecode","/user/binder","/pay/**")
                .excludePathPatterns("/swagger-resources/**", "/webjars/**", "/v2/**", "/swagger-ui.html/**");  //放行swagger

    }
}
